using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// PrintQueue Test Class
  /// </summary>
  [TestClass]
  public class TestPrintQueue
  {
    #region Class Variables
    private CdoPrms<DOPrintQueue>		m_PrintQueue;
    private CdoPrmsList<DOPrintQueue>	m_AllPrintQueue;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestPrintQueue()
    {
      // Create the data objects
      this.m_PrintQueue	= new CdoPrms<DOPrintQueue>();
      this.m_AllPrintQueue	= new CdoPrmsList<DOPrintQueue>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all PrintQueue data objects
    /// </summary>
    [TestMethod]
    public void PrintQueueRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllPrintQueue.DataObject = new DOPrintQueue();
      this.m_AllPrintQueue.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllPrintQueue.PerformAction())
      {
        // Assert the errors
        if (this.m_AllPrintQueue.Errors.Count > 0) { Assert.Fail(this.m_AllPrintQueue.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new PrintQueue
    /// </summary>
    [TestMethod]
    public void PrintQueueCreate()
    {
      // Set up the data object for creation
      this.m_PrintQueue.DataObject.FileName = "Test FileName";
      this.m_PrintQueue.DataObject.FilePath = "Test FilePath";
      this.m_PrintQueue.DataObject.UserName = "Test UserName";
      this.m_PrintQueue.DataObject.PrinterName = "Test PrinterName";
      this.m_PrintQueue.DataObject.PrinterFileName = "Test PrinterFileName";
      this.m_PrintQueue.DataObject.PrintCopies = 10;
      this.m_PrintQueue.DataObject.Date = DateTime.Now;
      this.m_PrintQueue.DataObject.Printed = false;
      this.m_PrintQueue.DataObject.PrintedDate = DateTime.Now;
      this.m_PrintQueue.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_PrintQueue.PerformAction())
      {
        // Assert the errors
        if (this.m_PrintQueue.Errors.Count > 0) { Assert.Fail(this.m_PrintQueue.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific PrintQueue
    /// </summary>
    [TestMethod]
    public void PrintQueueRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_PrintQueue.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_PrintQueue.DataObject.Id = 10;
      }

      // Set up the data object action for retrieval
      this.m_PrintQueue.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_PrintQueue.PerformAction())
      {
        // Assert the errors
        if (this.m_PrintQueue.Errors.Count > 0) { Assert.Fail(this.m_PrintQueue.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
